local lhs "cog"
local rhs "hours"
local robust "simple"
local controls "${CONTROLlist_`lhs'}"
local subsample = "$subsample"
local type "hom"

qui {
	local cnt=100
	capture program drop ccn_hom
	matrix actual_estimates_mat = J(`cnt',4,-9)
	local rowcounter = 0
	forvalues K=1(1)100 {
		noisily display "LHS=`lhs', RHS=`rhs', SE=`robust', K=`K', $S_DATE, $S_TIME"
		local rowcounter = `rowcounter'+1
		use "$datapath/003_cluster_`subsample'_`lhs'.dta", clear
		qui tab X_`K', generate(dumX_`K'_)

		qui ccn_hom symmetric `K' `rhs' `lhs' `robust' "`controls'" het_tobit
		matrix actual_estimates_mat[`rowcounter',1] = r(BETA)
		matrix actual_estimates_mat[`rowcounter',2] = r(SE)		
		matrix actual_estimates_mat[`rowcounter',3] = r(ESAMP)
		matrix actual_estimates_mat[`rowcounter',4] = `K'
	}
}
mat colnames actual_estimates_mat = b_HetSymm se_HetSymm Neff_HetSymm Kcluster
clear
qui svmat actual_estimates_mat, names(col)
gen LHS="`lhs'"
gen RHS="`rhs'"
replace b_HetSymm=100*b_HetSymm
replace se_HetSymm=100*se_HetSymm
save "$datapath/000_`type'_byK.dta", replace
